// pages/Census/customer-list.js
const Controllers = require('../../controllers/ControllerCensus').controller;
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    details: [
      {
        text: '昨日订单',
        value: 0,
        key: 'yesterDayNum'
      },
      {
        text: '本周订单',
        value: 0,
        key: 'thisWeekNum'
      },
      {
        text: '本月订单',
        value: 0,
        key: 'thisMonthNum'
      },
      {
        text: '上月订单',
        value: 0,
        key: 'lastMonthNum'
      },
      {
        text: '用户总数',
        value: 0,
        key: 'totalAccountNum'
      },
      {
        text: '新增用户',
        value: 0,
        key: 'newNum'
      },
      {
        text: '活动数量',
        value: 0,
        key: 'activityNum'
      },
      {
        text: '云商品订单',
        value: 0,
        key: 'cloudNum'
      },
    ],
    page: {
      pageNumber: 1,
      pageSize: 20
    },
    list: [],
    totalRow: 0
  },
  shopData() {
    var that = this;
    var page = that.data.page;
    Controllers.shopData(page).then(res => {
      console.log('shopData--res==', res);
      const { code, data, desc } = res;
      const { list, totalRow } = data.page;
      that.setData({
        list,
        totalRow,
        allNum:data.shopNum
      })

    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    that.shopData();
  },
  openPage(e) {
    var url = e.currentTarget.dataset.url;
    if (url) {
      app.openPage({ url });
    } else {
      wx.showToast({
        title: '未获取页面路径',
        icon: 'none'
      });
    }
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})